package com.gisinfo.minio.web.controller;

import cn.hutool.core.io.FileUtil;
import com.gisinfo.minio.web.util.MinioUtilService;
import com.gisinfo.minio.web.util.MultipartFileToFile;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.File;
@RestController
public class TestController {

    @Resource
    private MinioUtilService minioUtilService;

    @PostMapping("/up")
    public String uploadOneTest(MultipartFile multipartFile)throws Exception{
        File zipfile = MultipartFileToFile.multipartFileToFile(multipartFile);
        return minioUtilService.putObject("test", "fasdfdsafsdlkjh/" + zipfile.getName(), FileUtil.getInputStream(zipfile));
    }
}
